Findstr command the Grep equivalent for Windows
It has been a while since I use a computer with Windows Operating System. However, I have no choice today since I'm working on a computer provided by client.
In the course of understanding the legacy codes....I need to search the legacy source codes with the grep command. Wait, there's no grep command in Windows!
A friend introduces this nifty tool - findstr
. The grep equivalent command in Windows world.
For example :
In Linux
$ ls -ls | grep filename
In Windows
c:\> dir | findstr filename
For multiple strings search with case insensitive example :
In Linux
$ ls -ls | grep -iE "testdata|lifo"
In Windows - empty space to replace pipe |
for multiple strings
c:\> dir | findstr -i "testdata lifo"
And to search through a list of file example
In Linux
$ grep searchtag -lr /path/directory
In Windows
c:\> findstr /M searchtag c:\directory\*
Hope this helps!
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.3k Golang : Of hash table and hash map
+17.1k Golang : Get number of CPU cores
+8.1k Golang : What fmt.Println() can do and println() cannot do
+7.5k Golang : Scanf function weird error in Windows
+24.1k Golang : Fix type interface{} has no field or no methods and type assertions example
+12.6k Golang : Forwarding a local port to a remote server example
+3.8k Golang : Switch Redis database redis.NewClient
+8.3k Golang : Metaprogramming example of wrapping a function
+13k Python : Convert IPv6 address to decimal and back to IPv6
+7k Golang : Levenshtein distance example
+33.8k Golang : All update packages with go get command
+16.5k Golang : Send email and SMTP configuration example